console.log('Starting test...');

import fetch from 'node-fetch';

async function simpleTest() {
    try {
        console.log("Testing network connectivity...");
const http = require('http');

const options = {
    hostname: 'localhost',
    port: 8000,
    path: '/api/v1/index/category',
    method: 'GET'
};

const req = http.request(options, (res) => {
    console.log(`STATUS: ${res.statusCode}`);
    console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
    
    let data = '';
    res.on('data', (chunk) => {
        data += chunk;
    });
    
    res.on('end', () => {
        console.log('Response:', data);
    });
});

req.on('error', (e) => {
    console.error(`Problem with request: ${e.message}`);
});

req.setTimeout(5000, () => {
    console.log('Request timeout');
    req.destroy();
});

req.end();
        const response = await fetch('http://localhost:8000/api/v1/admin/data/info', {
            method: 'GET',
            headers: {
                'Authorization': 'Bearer admin_token'
            }
        });
        
        console.log('Response status:', response.status);
        const text = await response.text();
        console.log('Response body:', text);
        
    } catch (error) {
        console.error('Error:', error);
    }
}

simpleTest();
